﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;
using Facade;


namespace Edu_Examination.Lib
{
    public static class doConnection
    {
        public static string url = null;
        static TcpChannel channel;
        private static SuperFacade _superFacade;

        public static SuperFacade SuperFacade
        {
            get
            {
                if (_superFacade == null)
                {
                    if (channel == null)
                    {
                        channel = new TcpChannel();
                        ChannelServices.RegisterChannel(channel, false);
                    }
                    try
                    {
                        _superFacade = (SuperFacade)RemotingServices.Connect(typeof(SuperFacade), url + "SuperFacade");
                    }
                    catch (Exception)
                    {
                        System.Windows.Forms.MessageBox.Show("Please restart Client !");
                        _superFacade = null;
                    }
                }
                return _superFacade;
            }

        }
    }
}
